<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<div class="box">
			<div><h3>测测你的身材</h3></div>
			<div>
				<span>身高（厘米） </span>
				<input value="" id="sg" />
			</div>
			<div>
				<span>体重（公斤） </span>
				<input value="" id="tg" />
			</div>
			<div>
				<span>性别</span>
				<input type="radio" name="xbie" id="xb" value="男"/>男
				<input type="radio" name="xbie" id="xb2" value="女"/>女
			</div>
			<div>
				<button onclick="button()">开始测算</button>
			</div>
			<div class="jgji"> 
				<span>结果：</span>
				<input id="zhjg" />
			</div>+
		</div>
	</body>
</html>
<script>
		function button(){
			var sgs = document.getElementById("sg").value;
			var tgs = document.getElementById("tg").value;
			var xbsc = document.getElementsByName("xbie");
			var xbdanxuan,jieguo;
			for (var i=0; i<xbsc.length;i++) {
				if(xbsc[i].checked){
					xbdanxuan = xbsc[i].value;
					break;
				}
			}
			if(xbdanxuan=="男"){
				jieguo= (sgs-100)*0.90;
			}else{
				jieguo= (sgs-105)*0.92;
			}
			// (（实际 - 标准）/标准体重)*100
			var shiji = ((tgs-jieguo) /jieguo)*100
			var sdfsdf;
			if(shiji>=20){
				sdfsdf="肥胖"
			}else if(shiji>=10){
				sdfsdf="超重"
			}else if(shiji<=-20){
				sdfsdf="严重消瘦"
			}else if(shiji<=-10){
				sdfsdf="瘦"
			}else{
				sdfsdf="正常体重"
			}
			document.getElementById("zhjg").value=sdfsdf;
		}
		
</script>

<style>
	.box{
		border: 1px solid #eee;
		width: 300px;
		text-align: center;
		line-height: 35px;
	}
	.box .jgji{
		background-color: rgb(235, 235, 228);
	}
</style>